package com.cndw.kungfu.model.activity;

import java.text.ParseException;
import com.cndw.kungfu.config.ConstantsModel;
import com.cndw.kungfu.core.MemoryDataObject;
import com.cndw.kungfu.ext.TimeProcesser;

public class Quiz extends MemoryDataObject{
	/**
	 * 当前问题Id
	 */
	private int curQueId;
	
	/**
	 * 答对次数
	 */
	private int rightCount;
	
	/**
	 * 答错次数
	 */
	private int wrongCount;
	
	/**
	 *正确答案次数
	 */
	private int RightAnswerNum = ConstantsModel.quizInitRightAnswer;
	
	/**
	 * 读题时间
	 */
	private int readQueTime;
	
	/**
	 * 上个问题是否回答
	 */
	private boolean lastQueReply;
	public int getCurQueId() {
		return curQueId;
	}

	public void setCurQueId(int curQueId) {
		this.curQueId = curQueId;
	}

	public int getRightCount() {
		return rightCount;
	}

	public void setRightCount(int rightCount) {
		this.rightCount = rightCount;
	}

	public int getWrongCount() {
		return wrongCount;
	}

	public void setWrongCount(int wrongCount) {
		this.wrongCount = wrongCount;
	}

	public int getRightAnswerNum() {
		return RightAnswerNum;
	}

	public void setRightAnswerNum(int rightAnswerNum) {
		RightAnswerNum = rightAnswerNum;
	}
	
	public int getReadQueTime() {
		return readQueTime;
	}

	public void setReadQueTime(int readQueTime) {
		this.readQueTime = readQueTime;
	}

	public boolean isLastQueReply() {
		return lastQueReply;
	}

	public void setLastQueReply(boolean lastQueReply) {
		this.lastQueReply = lastQueReply;
	}

	@Override
	public boolean isCanGc() {
		boolean gc = true;
		int curTime = TimeProcesser.getUnixTime();
		boolean activityTime = false;
		try {
			activityTime = curTime > TimeProcesser.getUnixTimeByString(ConstantsModel.quizActivityBeginTime) && curTime < TimeProcesser.getUnixTimeByString(ConstantsModel.quizActivityEndTime);
		} catch (ParseException e) {
			e.printStackTrace();
		} 
		int i = 0;
		for(int[] time : ConstantsModel.quizTime){
			i++;
			if(TimeProcesser.inTimePeriod(time[0], time[1])){
				gc = false;
				break;
			}
			if(i > ConstantsModel.quizNormalRound && !activityTime){
				break;
			}
		}
		return gc;
	}
}
